import {defineStore} from "pinia";
import {getLocalStorage, setLocalStorage} from "@/utils";
import {StorageEnum} from '@/enums/storageEnum'

const {Z_INFORMATION_IS_EDIT} = StorageEnum
const storageIsEdit: string = getLocalStorage(Z_INFORMATION_IS_EDIT)

export const useEditAndReadStore = defineStore({
    id: 'editAndReadStore',
    state: () => ({
        // 参数字典集合
        isEdit: null
    }),
    getters: {
        getIsEdit(): any {
            if (this.isEdit === null) {
                this.isEdit = storageIsEdit
            }
            return this.isEdit
        }
    },
    actions: {
        setValue(value: any) {
            this.isEdit = value
            setLocalStorage(Z_INFORMATION_IS_EDIT, this.isEdit)
        }
    }
})

